#!/bin/sh
NM=nm

case $1 in
   32)
      SYMBOL_START=13
      ;;
   64)
      SYMBOL_START=20
      ;;
   *)
      SYMBOL_START=13
      ;;
esac
shift

echo "LIBRARY libsusancats.dll"
echo "EXPORTS"
echo " "

#
# Get all function symbols.
#
for i in $*
do
   header=1
   ${NM} $i | grep "^[0-9a-f]* T " | cut -c${SYMBOL_START}- > /tmp/sym.$$
   while read symbol
   do
      if [ ${header} = 1 ]; then
         echo "; $i"
         header=0
      fi
      echo "${symbol}"
   done < /tmp/sym.$$
   if [ ${header} = 0 ]; then
      echo " "
   fi
   rm -f /tmp/sym.$$
done

#
# Get all data symbols.
#
for i in $*
do
   header=1
   ${NM} $i | grep "^[0-9a-f]* D " | cut -c${SYMBOL_START}- > /tmp/sym.$$
   while read symbol
   do
      if [ ${header} = 1 ]; then
         echo "; $i"
         header=0
      fi
      echo "${symbol}"
   done < /tmp/sym.$$
   if [ ${header} = 0 ]; then
      echo " "
   fi
   rm -f /tmp/sym.$$
done
